<template>
  <div>
    <van-nav-bar safe-area-inset-top placeholder :title="$t('alarmList')" left-arrow fixed @click-left="onClickLeft" />

    <van-pull-refresh v-model="isLoading" :pulling-text="$t('PullingText')" :loosing-text="$t('PullingText')" :success-text="$t('refreshSuccee')" @refresh="onRefresh">
      <van-cell class="left" :title="errorMsg" icon="warning-o" v-for="(errorMsg,i) in errorArr" :key="i" />
    </van-pull-refresh>
    <div class="emptyBox" v-if="errorArr.length==0">
      <div class="imgBox">
        <img src="../../assets/empty.png" alt="">
      </div>
      <div class="txt">{{$t('NoData')}}</div>
    </div>
  </div>
</template>

<script>
export default {
  data(){
    return {
      isLoading:false,
      activeNames:[],
      bdPwd:sessionStorage.getItem('bdPwd'),
      inverterType:localStorage.getItem('inverterType'),
      errorArr:[]
    }
  },
  methods: {
    onClickLeft(){
      this.$router.push({path:'/localin'});
    },
    async getInfors(){
      this.errorArr=[];
      this.comm.loadingShow();
      let data = await this.SETAPI.LocalIn({'optType':'ReadRealTimeData','pwd':this.bdPwd});
      if(data!=null&&data!=undefined){
        if(data.Error!=null&&data.Error!=undefined){
          let errors=(data.Error.ErrorCode).split(",");
          for(let i=0;i<errors.length;i++){
            this.errorArr.push(this.errorMsg.getErrorMsg(this.inverterType)[errors[i]]);
          }
        }else{
          this.errorArr=[];
        }
      }else{
        this.comm.tipsShow('InvNoResponse');
      }
    },
    onRefresh(){
      this.isLoading=false;
      this.getInfors();
    }
  },
  mounted(){
    setTimeout(()=>{
      this.getInfors();
    },1000);
  }
}
</script>

<style scoped lang="less">
.left{
  text-align: left;
}
.emptyBox{
  width: 100%;
  margin: 20px auto;
  .imgBox{
    width: 180px;
    height: 180px;
    margin: 0 auto;
  }
  img{
    width: 180px;
    height: 180px;
  }
  .txt{
    width: 100%;
    text-align: center;
    color:#969799;
  }
}
</style>
